Skip to content

Conversation

notriddle
Copy link
Contributor

This can't do the "correct" thing, and check if the method is defined, because FnCtxt::lookup_method isn't accessible in Clippy.

To work around this problem, we convert method calls to FQP syntax if the user specifies a full path as a replacement. If they specify only a name, then we only replace the name. Since clippy.toml resolves paths from the top level of the crate, this is basically guaranteed to produce a correct result, if we ignore method call adjustments like autoderef.

changelog: [disallowed_methods]: correctly handle methods called by FQP

Fixes #15067

This can't do the "correct" thing, and check if the method is defined,
because `FnCtxt::lookup_method` isn't accessible in Clippy.

To work around this problem, we convert method calls to FQP syntax
if the user specifies a full path as a replacement. If they specify
only a name, then we only replace the name. Since clippy.toml
resolves paths from the top level of the crate, this is basically
guaranteed to produce a correct result, if we ignore method call
adjustments like autoderef.
@rustbot
Copy link
Collaborator

rustbot commented Jul 10, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 10, 2025
Copy link
Contributor

@ada4a ada4a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried looking into this yesterday, so just chiming in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

disallowed-methods auto-fixes are unreliable
4 participants